//
//  MYXNewReleaseTopCell.m
//  meiyinxiang
//
//  Created by lizidi on 2018/1/5.
//  Copyright © 2018年 hbjApple. All rights reserved.
//

#import "MYXNewReleaseTopCell.h"
#import "MYXReleaseTopView.h"
#import "UIView+Additions.h"
#import "UIImageView+LBBlurredImage.h"

@interface MYXNewReleaseTopCell()
//背景 头像  性别  点赞 底部View
@property(nonatomic,strong)UIImageView *bgView,*headView,*sexView,*zanView,*bottomView;
//昵称  签名  点赞次数
@property(nonatomic,strong)UILabel * nameLabel,*detialLabel,*numLabel;
//底部线条
@property(nonatomic,strong)UIView * lineView;



@end

@implementation MYXNewReleaseTopCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        
        if (!_bgView) {
            _bgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, [MyAdapter laDapter:225])];
            [self addSubview:_bgView];
            //            [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            //                make.left.right.top.offset(0);
            //                make.height.offset([MyAdapter laDapter:225]);
            //            }];
        }
        
        if (!_headView) {
            _headView = [[UIImageView alloc]init];
            [_headView.layer setCornerRadius:[MyAdapter laDapter:41]];
            _headView.layer.masksToBounds = YES;
            [_bgView addSubview:_headView];
            [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.offset([MyAdapter laDapter:-15]);
                make.height.width.offset([MyAdapter laDapter:82]);
                make.top.offset([MyAdapter laDapter:104]);
            }];
        }
        if (!_sexView) {
            _sexView = [[UIImageView alloc]init];
            [self addSubview:_sexView];
            [_sexView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(_headView.mas_left).offset([MyAdapter laDapter:4]);
                make.bottom.equalTo(_headView.mas_bottom);
                make.height.width.offset([MyAdapter laDapter:17]);
            }];
        }
        if (!_nameLabel) {
            _nameLabel = [[UILabel alloc]init];
            _nameLabel.textColor = RGBACOLOR(255, 255, 255, 1);
            _nameLabel.textAlignment = 2;
            _nameLabel.font = [MyAdapter lfontADapter:16];
            [_bgView addSubview:_nameLabel];
            [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(_headView.mas_left).offset([MyAdapter laDapter:-9]);
                make.height.offset([MyAdapter laDapter:16]);
                make.centerY.equalTo(_headView);
            }];
        }
        if (!_detialLabel) {
            _detialLabel = [[UILabel alloc]init];
            _detialLabel.textColor = RGBACOLOR(255, 255, 255, 1);
            _detialLabel.textAlignment = 2;
            _detialLabel.font = [MyAdapter lfontADapter:12];
            [_bgView addSubview:_detialLabel];
            [_detialLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(_headView.mas_left).offset([MyAdapter laDapter:-9]);
                make.height.offset([MyAdapter laDapter:12]);
                make.top.equalTo(_nameLabel.mas_bottom).offset([MyAdapter laDapter:5]);
            }];
        }
//        if (!_bottomView) {
//            _bottomView = [[UIImageView alloc]init];
//            _bottomView.image = [UIImage imageNamed:@"bg-shadow"];
//            [self addSubview:_bottomView];
//            [_bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.left.offset([MyAdapter laDapter:15]);
//                make.right.offset([MyAdapter laDapter:-15]);
//                make.height.offset([MyAdapter laDapter:80]);
//                make.centerY.equalTo(_bgView.mas_bottom).offset([MyAdapter laDapter:15]);
//            }];
//
//        }
//
//        MYXReleaseTopView * fangke = [[MYXReleaseTopView alloc]init];
//        [fangke configDataWithTitle:@"访客" Num:@"20"];
//        [_bottomView addSubview:fangke];
//        [fangke mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.offset([MyAdapter laDapter:40]);
//            make.top.equalTo(_bottomView.mas_top).offset([MyAdapter laDapter:10]);
//            make.height.offset([MyAdapter laDapter:60]);
//        }];
//        MYXReleaseTopView * fachu = [[MYXReleaseTopView alloc]init];
//        [fachu configDataWithTitle:@"发出" Num:@"20"];
//        [_bottomView addSubview:fachu];
//        [fachu mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(_bottomView.mas_top).offset([MyAdapter laDapter:10]);
//            make.height.offset([MyAdapter laDapter:60]);
//            make.centerX.equalTo(self.contentView).offset([MyAdapter laDapter:-25]);
//        }];
//        MYXReleaseTopView * shoudao = [[MYXReleaseTopView alloc]init];
//        [shoudao configDataWithTitle:@"收到" Num:@"20"];
//        [_bottomView addSubview:shoudao];
//        [shoudao mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.right.equalTo(self.mas_right).offset([MyAdapter laDapter:-100]);
//            make.top.equalTo(_bottomView.mas_top).offset([MyAdapter laDapter:10]);
//            make.height.offset([MyAdapter laDapter:60]);
//        }];
        
        if ([MYXMemberMdel sharedInstance].userinfo.image) {
            [self.headView sd_setImageWithURL:[NSURL URLWithString:[MYXMemberMdel sharedInstance].userinfo.image] placeholderImage:[UIImage imageNamed:@"AppIcon"]];
            self.headView.contentMode = UIViewContentModeScaleAspectFill;
            [self.bgView sd_setImageWithURL:[NSURL URLWithString:[MYXMemberMdel sharedInstance].userinfo.image] placeholderImage:[UIImage imageNamed:@"AppIcon"]];
            // 方法2,对背景图片进行毛玻璃效果处理,参数blurRadius默认是20,可指定,最后一个参数block回调可为nil
            [self.bgView setImageToBlur:self.bgView.image blurRadius:5 completionBlock:nil];
            self.bgView.contentMode = UIViewContentModeScaleAspectFill;
            self.bgView.layer.masksToBounds = YES;
            self.bgView.userInteractionEnabled = YES;
            
        }else{
            self.headView.image =[UIImage imageNamed:@"AppIcon"];
        }
        if ([MYXMemberMdel sharedInstance].userinfo.username.length>0) {
            self.nameLabel.text =[MYXMemberMdel sharedInstance].userinfo.username;
        }else{
            self.nameLabel.text =[MYXMemberMdel sharedInstance].userinfo.phone;
        }
        self.detialLabel.text = [MYXMemberMdel sharedInstance].userinfo.signature;
        if ([[MYXMemberMdel sharedInstance].userinfo.sex isEqualToString:@"1"]) {
            self.sexView.image = [UIImage imageNamed:@"men"];
        }else{
            self.sexView.image = [UIImage imageNamed:@"women"];
        }
        
        
    }
    return self;
}




- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end

